{extend name="main/index" /}
{block name="main"}
<div class="content-page">
    <div class="content">
        <h1 class="text-center h1">管理员信息</h1>
        <table class="table table-bordered text-center">
            <tr>
                <th class="active col-xs-1 text-center h4">编号</th>
                <th class="active col-xs-2 text-center h4">用户名</th>
                <th class="active col-xs-2 text-center h4">电话</th>
                <th class="active col-xs-2 text-center h4">所属角色</th>
                <th class="active col-xs-5 text-center h4">操作</th>
            </tr>
            <!--遍历-->
            {volist name="list" id="v"}
            <tr>
                <td class="info h4">{$v['au_id']}</td>
                <td class="info" style="line-height: 30px;">{$v['au_name']}</td>
                <td class="info" style="line-height: 30px;">{$v['au_tel']}</td>
                {if !empty($role_name[$v['au_id']]) }
                    <td class="info col-xs-3" style="line-height: 30px;">
                        {volist name="role_name[$v['au_id']]" id="k"}
                            <span>{$k['r_rolename']}</span>
                        {/volist}
                    </td>
                {/if}
                {if empty($role_name[$v['au_id']]) }
                    <td class="info col-xs-3" style="line-height: 30px;"></td>
                {/if}
                <td class="info">
                    <a class="btn btn-warning" href="{:url('admin/con1/addRole',['au_id'=>$v['au_id']])}">角色更改</a>
                    <button type="button" class="btn btn-primary">修改信息</button>
                    <button type="button" class="btn btn-danger del-btn" data-id="{$v['au_id']}">删除信息</button>
                </td>
            </tr>
            {/volist}
        </table>
    </div>
</div>



{js href="/static/index/js/jquery.min.js"}
{js href="/static/index/js/bootstrap.min.js"}
<script>
    $('.del-btn').click(function () {
        var au_id = $(this).attr('data-id');
        if (confirm('你确定要 【删除】 吗？')) {
            var obj = $(this).parents('tr');
            delAjax(au_id,obj);
        }
    });

    function delAjax(id,obj) {
        $.ajax({
            type:'delete',
            url:'/con1/' + id,
            dataType: 'json',
            success: function (data) {
                // console.log(data);
                if (data.status) {
                    toastr.success(data.info);
                    obj.remove();
                } else {
                    toastr.error(data.info, 'FBI WARNING:');
                }
            },
            error: function () {
                alert('执行失败');
            }
        });
    }
</script>
{/block}



